﻿/*
Copyright (c) 2010 Vratislav Cermak (vratacermak@gmail.com)
 
This file is part of TeachMe Project. See http://code.google.com/p/teach-me for more information.
 
TeachMe is an open source project. Using of TeachMe is free of charge.
It is distributed under GNU General Public License version 3 (GPLv3).
GPLv3 can be found at http://www.gnu.org/licenses/gpl.html.
 
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

using System;
using System.Collections.Generic;

namespace TeachMe.Application.Translators
{
    public class Translators
    {
        private static readonly List<ITranslationProvider> Providers;

        static Translators()
        {
            Providers = new List<ITranslationProvider>();

            Providers.Add(new Seznam());
        }

        public static ITranslationProvider[] GetAvailableTranslators(Languages.Item from, Languages.Item to)
        {
            List<ITranslationProvider> result = new List<ITranslationProvider>();

            foreach (ITranslationProvider provider in Providers)
            {
                foreach (Item<string, string> item in provider.Directions)
                {
                    if (String.Compare(item.First, from.Code, true) == 0 && String.Compare(item.Second, to.Code, true) == 0)
                    {
                        result.Add(provider);

                        break;
                    }
                }
            }

            return result.ToArray();
        }
    }
}
